package com.parsechina.hpush.rest.account.web;

import com.parsechina.hpush.rest.account.domain.Account;
import com.parsechina.hpush.rest.account.service.AccountService;
import com.parsechina.hpush.rest.base.web.View;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author linfeng
 * @date 2019-08-21
 **/
@RestController
@RequestMapping("/account")
public class AccountController {

    private final AccountService accountService;

    @Autowired
    public AccountController(AccountService accountService) {
        this.accountService = accountService;
    }

    @ResponseBody
    @PostMapping("/register")
    public View<Account> register(@RequestBody Account account) {

        boolean saveFlag = accountService.save(account);
        if (saveFlag) {
            return View.ofOk(account);
        }

        return View.ofError("注册失败");
    }



}
